<template>
	<view class="content">
		<view v-if="current == 0" style="width: 100%;">
			<home></home>
		</view>
		<view v-if="current == 3" style="width: 100%;">
			<share></share>
		</view>
		<view v-if="current == 1" style="width: 100%;">
			<news></news>
		</view>
		<view v-if="current == 2" style="width: 100%;">
			<community></community>
		</view>

		<view v-if="current == 4" style="width: 100%;">
			<mine></mine>
		</view>

		<u-tabbar :value="current" @change="beforeSwitch" activeColor="#0A5259" inactiveColor="#666"
			:customStyle="{paddingTop: '15rpx', zIndex:999}">
			<view>
				<u-tabbar-item text="首页">
					<image class="u-page__item__slot-icon" mode="heightFix" slot="active-icon"
						src="https://resourse.cnlhjt.com/upload/20220829/a5d04693b3a845a6c13b172e15294d90.png" style="width: 55rpx;height: 55rpx;"></image>
					<image class="u-page__item__slot-icon" mode="heightFix" slot="inactive-icon"
						src="https://resourse.cnlhjt.com/upload/20220829/3d1bf04c02325cbfa4299c2f00d138a4.png" style="width: 55rpx;height: 55rpx;"></image>
				</u-tabbar-item>
			</view>
			<view>
				<u-tabbar-item text="社区">
					<image class="u-page__item__slot-icon" mode="heightFix" slot="active-icon"
						src="https://resourse.cnlhjt.com/upload/20220829/72d3830840469be2ba5083d4a9d3a25b.png" style="width: 55rpx;height: 55rpx;"></image>
					<image class="u-page__item__slot-icon" mode="heightFix" slot="inactive-icon"
						src="https://resourse.cnlhjt.com/upload/20220829/f93af5a11c0b754356933fa8c092d323.png" style="width: 55rpx;height: 55rpx;"></image>
				</u-tabbar-item>
			</view>
			<view>
				<u-tabbar-item text="龙庭社圈">
					<image class="u-page__item__slot-icon" mode="heightFix" slot="active-icon"
						src="https://resourse.cnlhjt.com/upload/20220829/f93cecaea613d11af6daec8363273e4a.png"
						style="width: 100rpx;height: 100rpx;margin-top: -48rpx;"></image>
					<image class="u-page__item__slot-icon" mode="heightFix" slot="inactive-icon"
						src="https://resourse.cnlhjt.com/upload/20220829/bca0e175d9f3ff064831cb4f02a6baf1.png"
						style="width: 100rpx;height: 100rpx;margin-top: -48rpx;"></image>
				</u-tabbar-item>
			</view>
			<view>
				<u-tabbar-item text="邻享">
					<image class="u-page__item__slot-icon" mode="heightFix" slot="active-icon"
						src="https://resourse.cnlhjt.com/upload/20220829/3bba4f6de8c5fbb4cd0dc2eff5ae1d58.png" style="width: 55rpx;height: 55rpx;"></image>
					<image class="u-page__item__slot-icon" mode="heightFix" slot="inactive-icon"
						src="https://resourse.cnlhjt.com/upload/20220829/3a9bc1e7a01204f1e409980bd9f4d417.png" style="width: 55rpx;height: 55rpx;"></image>
				</u-tabbar-item>
			</view>
			<view>
				<u-tabbar-item text="我的">
					<image class="u-page__item__slot-icon" mode="heightFix" slot="active-icon"
						src="https://resourse.cnlhjt.com/upload/20220829/7a3fdb63a09322906771d4f443c42736.png" style="width: 55rpx;height: 55rpx;"></image>
					<image class="u-page__item__slot-icon" mode="heightFix" slot="inactive-icon"
						src="https://resourse.cnlhjt.com/upload/20220829/825e24f8d5a21f1e4bfc7473523e26da.png" style="width: 55rpx;height: 55rpx;"></image>
				</u-tabbar-item>
			</view>

		</u-tabbar>
	</view>
</template>

<script>
	import home from "@/pages/index/home.vue";
	import share from "@/pages/index/share.vue";
	import community from "@/pages/index/community.vue";
	import mine from "@/pages/index/mine.vue";
	import news from "@/pages/index/news.vue";
	import {
		getTitle
	} from "@/service/configService.js";
	export default {
		data() {
			return {
				current: 0
			}
		},
		components: {
			home: home,
			share: share,
			community: community,
			mine: mine,
			news: news
		},
		mounted() {
			if(this.$store.state.isSplash==false){
				uni.redirectTo({
					url:'../welcome/welcome'
				})
			}
		},
		onLoad(options) {
			if(options.current==3){
				this.current=3
			}
			
			// console.log('登录状态' + this.$store.state.isLogin);
			getTitle().then(this.getTitle);
		},
		methods: {
			getTitle(res) {
				if(res.code == 200){
					uni.$u.vuex('appTitle', res.result);
					
				}
			},
			beforeSwitch(index) {

				if (this.current !== index) {
					this.toTop();
				}
				this.current = index;

			},
			toTop() {
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 100
				});
			},
		}
	}
</script>

<style>
	.content {
		background-color: #FFFFFF;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding-bottom: 20rpx;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
